When an identifier is referred to, it will look for a definition within a local scope. So, in a program like:
(define demo_scope
(lambda ()
(let ([y 5])
(let ([y 9][z (sub1 y)])
(+ y z)))))(define occurs-in?
(lambda (x ls)
(if (null? ls)
#f
(if (= x (car ls))
#t
(occurs-in? x (cdr ls))))))Output:
"3.rkt"> occurs-in?
#<procedure:occurs-in?>
"3.rkt"> (occurs-in? 5 '(1 2 3 4))
#f
"3.rkt"> (occurs-in? 5 '(1 2 3 4 5))
#tNote to self: Revise the section from 19:41 in order to understand the finer details of recursion and something else that I have not initially caught.
So what I get from that is:
(+ 1 (a (sub1 p))), where the a is the function, and the recursive callback has the + 1 around it.